package com.sciencep.pro.admin.system.controller;

import com.sciencep.pro.common.domain.QueryRequest;
import com.sciencep.pro.common.domain.ResponseResult;
import com.sciencep.pro.core.domain.dto.user.UserListRequestTO;
import com.sciencep.pro.core.service.IUserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@Slf4j
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    IUserService userService;


    @GetMapping("/list")
    public ResponseResult<Object> getUserList(QueryRequest queryRequest, UserListRequestTO userListRequestTO){

        return new ResponseResult<>().success(userService.getUserList(queryRequest,userListRequestTO));
    }

    @GetMapping("/users")
    public ResponseResult<Object> getUserList(){
        return new ResponseResult<>().success(userService.getUsers());
    }




    @GetMapping("/info")
    public ResponseResult<Object> info(){
        Map<String,String> map = new HashMap<>();
        map.put("name", "admin");
        map.put("roles", "[admin]");
        map.put("avatar", "https://oss.aliyuncs.com/aliyun_id_photo_bucket/default_handsome.jpg");
        return new ResponseResult<>().success(map);
    }


    //下面两个建议删除
    @PostMapping("/login")
    public ResponseResult<Object> login(){
        Map<String,String> map = new HashMap<>();
        map.put("token","token");
        return new ResponseResult<>().success(map);
    }

    @GetMapping("/loginOut")
    public ResponseResult<Object> loginOut(){
        return new ResponseResult<>().success();
    }

}
